home *** CD-ROM | disk | FTP | other *** search
- #ifndef FWWINDIB_H
- #define FWWINDIB_H
-
- //========================================================================================
- //
- // File: FWWinDIB.h
- // Release Version: $ 1.0d11 $
- //
- // Copyright: © 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWSTDDEF_H
- #include "FWStdDef.h"
- #endif
-
- #ifdef FW_BUILD_WIN
-
- //========================================================================================
- // Forward Class Declarations
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CColor;
- class FW_CLASS_ATTR FW_CWritableStream;
- class FW_CLASS_ATTR FW_CReadableStream;
-
- //========================================================================================
- // class FW_CPrivWinDIB
- // A small set of utility functions to work with DIBs.
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CPrivWinDIB
- {
- public:
-
- enum
- {
- kWinBitmapFileSignature = 0x4D42 // "BM"
- };
-
- DECLARE_HANDLE(HDIB);
-
- #ifdef FW_BUILD_WIN32
- typedef char* PixelBufferPtr;
- #endif
-
- #ifdef FW_BUILD_WIN16
- typedef char __huge* PixelBufferPtr;
- #endif
-
- // ----- Attributes
- static unsigned long GetPaletteSize(const BITMAPINFOHEADER* bmi);
- static PixelBufferPtr GetPixelBuffer(const BITMAPINFO* biPtr);
-
- static unsigned short GetColorTable(HDIB dib, FW_CColor*& colors);
- // NB: colors is allocated with "new" and should be freed!
-
- // ----- Conversion
- static HBITMAP ConvertToBitmap(HDIB dib, HPALETTE hPal = NULL);
- static HDIB ConvertFromBitmap(HBITMAP bitmapHandle, short bitDepth = 0, HPALETTE hPal = NULL);
-
- // ----- Palette
- static HPALETTE GetPalette(HDIB dib);
-
- // ----- Creation
- static HDIB CreateDIB(short bitDepth, short width, short height,
- short nbColors, const FW_CColor* colorTable,
- const void* pixels = NULL);
-
- static HDIB CreateCopy(HDIB dib);
-
- // ----- Persistence
- static void SaveToStream(const FW_CWritableStream& stream, HDIB dib, FW_Boolean bFileHeader);
- static HDIB LoadFromStream(const FW_CReadableStream& stream, FW_Boolean bFileHeader);
-
- // ----- Memory
- static void Free(HDIB dib);
-
- // ----- Implementation
- private:
- static void PrivInitHeader(BITMAPINFOHEADER& header, int width, int height, int bitDepth);
-
- static void PrivGetColorInfo(
- const BITMAPINFOHEADER& header,
- int& bitDepth,
- int& colorCount, // Will be 0 for 24-bit bitmap
- int& paletteSize);
- };
-
- //========================================================================================
- // class FW_CPrivWinBitmap
- // A small set of utility functions to work with device-dependent bitmaps
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CPrivWinBitmap
- {
- public:
- static short GetColorDepth(HBITMAP hBitmap);
-
-
- // CopyImage options
- enum
- {
- kCrop,
- kScale
- };
-
- static void CopyImage(
- HBITMAP hBmpDst, HPALETTE hPalDst, const RECT& rectDst,
- HBITMAP hBmpSrc, HPALETTE hPalSrc, const RECT& rectSrc,
- short options);
- };
-
- #endif // FW_BUILD_WIN
-
- #endif // FWWINDIB_H
-